<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class comp_garage extends Page
{
       public $HiddenRandom = null;
       public $hiddenComp = null;
       public $JTCompContactList = null;
       public $JTJavaScript2 = null;
       public $JTJavaScript1 = null;
       public $JTSiteTheme1 = null;
       function comp_garageCreate($sender, $params)
       {
       $comp = $_GET['company_id'];
       //$rand = $_GET['rand'];
       $this->hiddenComp->setValue($comp);
       //$this->HiddenRandom->setValue($rand);

       }



       function JTCompContactListShow($sender, $params)
       {
       $comp_id = $this->hiddenComp->getValue();
       //$rand = $this->HiddenRandom->getValue();

       if($comp_id==0)
       {
       $query1 = "select * from company_garage where company_id='".$_SESSION['rand']."'";
       }

       if($comp_id!=0)
       {
       $query1 = "select * from company_garage where company_id='".$_SESSION['company_id']."'";
       }

       $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {
            $auto = $row['auto_id'];
            //$comp_contact = "<a href=comp_contact_edit.php?contact_num=".$contact_num.">".$row['lname'].','.$row['fname']."</a>";
            $tools = "<img onclick=js_deleteContact('".$auto."','".$comp_id."') src='image/delete.png' title='delete' style='cursor:pointer' />";
            //$vend_name = "<div onclick=window.open('vendor_contact_edit.php?contact=".$contact_num."')>".$row['lname'].','.$row['fname']."<div/>";
            //$vend_name = "<a href='vendor_contact_edit.php?contact=".$contact_num."' target='_blank'>".$row['lname'].','.$row['fname']."</a>";

            $comp_garage = "<span style='color:blue;text-decoration:underline;cursor:pointer' onClick=editGarage('".$auto."') title='Edit Contact'>".$row['name']."</span>";


            $arr[] = array(
                        'Location Name' => $comp_garage,
                        'City' => $row['city'],
                        'Country' => $row['country'],
                        'Tools' => $tools
                        );


          }

            $this->JTCompContactList->setCellData($arr);


       }

}

global $application;

global $comp_garage;

//Creates the form
$comp_garage=new comp_garage($application);

//Read from resource file
$comp_garage->loadResource(__FILE__);

//Shows the form
$comp_garage->show();

?>